<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>个人信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" type="text/css" href="common/layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="common/bootstrap/css/bootstrap.css" media="all">
	<link rel="stylesheet" type="text/css" href="common/global.css" media="all">
	<link rel="stylesheet" type="text/css" href="css/personal.css" media="all">
</head>
<body>
<section class="layui-larry-box">
	<div class="larry-personal">
		<header class="larry-personal-tit">
			<span>员工信息</span>
		</header><!-- /header -->
		<div class="larry-personal-body clearfix">
			<form class="layui-form col-lg-5" action="" method="post" id="em_upinfo">
				<div class="layui-form-item">
					<label class="layui-form-label">姓名</label>
					<div class="layui-input-block">
						<input type="text" id="em_name" name="name"  autocomplete="off" class="layui-input" value="">
						<input type="text" id="em_id" name="id"  autocomplete="off" class="layui-input" value="" hidden="hidden">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">年龄</label>
					<div class="layui-input-block">
						<input type="text" id="em_age" name="age"  autocomplete="off" class="layui-input" value="">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">家庭住址</label>
					<div class="layui-input-block">
						<input type="text" id="admin_name" name="address"  autocomplete="off" class="layui-input" value="">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">手机号码</label>
					<div class="layui-input-block">
						<input type="text" id="em_phonenum" name="phonenum"  autocomplete="off" class="layui-input" placeholder="输入手机号码">
						<!--添加员工默认在职-->
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">状态</label>
					<div class="layui-input-inline">
						<select name="state" class="newsLook" lay-filter="browseLook" id="em_state">
							<option value="0" >在职</option>
							<option value="1" >离职</option>
						</select>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">性别</label>
					<div class="layui-input-block">
						<input type="radio" id="admin_sex1" name="sex" value="男" title="男" checked="false"><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><span>男</span></div>
						<input type="radio" id="admin_sex2" name="sex" value="女" title="女" checked="true"><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><span>女</span></div>
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" type="button" onclick="addemployee()" lay-filter="demo1">立即保存</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>


</section>
<script type="text/javascript" src="common/layui/lay/dest/layui.all.js"></script>
<script type="text/javascript" src="js/login.js"></script>
<script type="text/javascript" src="js/newslist.js"></script>
<script src="jsplug/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="jsplug/jparticle.jquery.js"></script>
<script type="text/javascript" src="common/layui/layui.js"></script>
<script type="text/javascript" src="js/token.js"></script>
 <script type="text/javascript">
	/**
	 * 修改员工信息(根据id)
	 * 先获取从url传来的参数
	 */
	$(function (){
		var id = location.search.split("=")[1];
		document.getElementById("em_id").value=id;
		$.post("/employee/toupdata",{id:id},function (res){
			$("#em_name").val(res.data.name);
			$("#em_age").val(res.data.age);
			$("#admin_name").val(res.data.address);
			$("#em_phonenum").val(res.data.phonenum);
			if (res.data.state==0){
				document.getElementById("em_state").options[0].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else {
				document.getElementById("em_state").options[1].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}

			if (res.data.sex=="男"){
				document.getElementById("admin_sex1").checked=true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else {
				//重新绘制表单
				document.getElementById("admin_sex2").checked=true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}


		},"json")
	})





	/*添加员工操作*/
	function addemployee(){
		$.post("/employee/saveemployee",$("#em_upinfo").serialize(),function(res){
			layer.confirm('员工添加成功，前往查看！', {
			icon: 1,        //会出现正确的图片
			btn: ['好']     //按钮
		}, function(){
			window.location.href="employee_table.html";//点击“好”后进行跳转
		});

		},"json")
}





	layui.use(['form','upload'],function(){
		var form = layui.form();
		form.render();
		layui.upload({
			url: '' ,//上传接口
			success: function(res){
				//上传成功后的回调
				console.log(res)
			}
		});

	});

</script>
</body>
</html>